#pragma once
#include <cstdlib>
#include <time.h>
std::string operation = "+-*/";

class task
{
public:
    task() {}

    task(int a, int b, char op) : _a(a), _b(b), _op(op)
    {
        char buffer[255];
        snprintf(buffer, sizeof(buffer), "%d %c %d = ?", _a, _op, _b);
        msg = buffer;
    }

    int operator()()
    {
        int result;
        char buffer[255];
        switch (_op)
        {
        case '+':
            result = _a + _b;
            break;
        case '-':
            result = _a - _b;
            break;
        case '*':
            result = _a * _b;
            break;
        case '/':
            if (_b == 0)
            {
                snprintf(buffer, sizeof(buffer), "除0错误");
                msg = buffer;
                return -1;
            }
            result = _a / _b;
            break;
        default:
            break;
        }
        snprintf(buffer, sizeof(buffer), "%d %c %d = %d", _a, _op, _b, result);
        std::cout << buffer;
        msg = buffer;
        return result;
    }

    ~task()
    {
        // do nothing
    }
    std::string msg;
private:
    int _a;
    int _b;
    char _op;
};


